import component from "../../../common/component";
import {Button, Col, Input, Popconfirm, Row} from "antd";
import EditModal from "./edit";
import EditAndDelBtn from "@/components/EditAndDelBtn";


class equtype extends component {
     //右上角 新建设备类型与删除选中 按钮
    getButtonRow(): null {
        return <>
            <Popconfirm
                title="你确定永久删除选中的数据吗？"
                onConfirm={this.deleteSelect}
                okText="确定"
                cancelText="取消">
                <Button className={'button-delete button-default'} type="primary" danger
                        loading={this.state.deleteLoading}>
                    删除选中
                </Button>
            </Popconfirm>
            <Button className={'button-delete button-default'} onClick={this.handleAdd} type="primary">
                新增设备类型
            </Button>
        </>;
    }
    //搜索栏  搜索栏不可指定搜索属性搜索
    getSearchRow(): null {
        return <Input.Group>
            <Row gutter={8}>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备编号" onPressEnter={this.reload}
                           name={'classCode'}/>
                </Col>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备类型" onPressEnter={this.reload}
                           name={'name'}/>
                </Col>
                <Col span={3}>
                    <Button type={'primary'} onClick={this.reload}>搜索</Button>
                </Col>
            </Row>
        </Input.Group>;
    }
    //主体部分页眉
    getColumns(): null {
        return [
            {
                title: '设备类型编号',
                dataIndex: 'classCode',//改
                key: 'classCode',
            },
            {
                title: '设备类型名称',
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: '设备数量',
                dataIndex: 'num',
                key: 'num',
            },
            {
                title: '备注',
                dataIndex: 'text',
                key: 'text',
            },
            {
                title: '操作',
                dataIndex: 'operation',
                fixed: 'right',
                render: (_, record) => {
                    return <EditAndDelBtn record={record} edit={this.edit} del={this.delete}/>
                },
            }
        ];
    }

    getEditModal(): null {
        return <EditModal {...this.state.editParam} cancelModal={this.cancelModal} reload={this.reload}
                          baseUir={this.state.baseUri}/>
    }
}

export default equtype;
